/*
 * Catherine.cpp
 *
 *  Created on: 01/09/2010
 *      Author: alex
 */

#include "Catherine.h"
#include "control/InputManager.h"
#include "control/CollisionManager.h"

using namespace utils;


Catherine::Catherine(unsigned myNumber) :
Player("img/sprites/catherine/dragon_stop.gif", "img/sprites/catherine/moving",
		"img/sprites/catherine/moving", "img/sprites/catherine/dragon_stop.gif",
		"img/sprites/catherine/dragon_stop.gif", myNumber), timeFire(0) {
}


Catherine& Catherine::update(int dt) {
	GameObject::update(dt);
	if (life <= 0) return *this;
	timeFire += dt;
	fire.update(dt);
	if (inputManager.isKeyPress(SDLK_LEFT, myNumber)) {
		rotate(dt, 0.1);
	} else if (inputManager.isKeyPress(SDLK_RIGHT, myNumber)) {
		rotate(dt, -0.1);
	}
	if (inputManager.isKeyPress(SDLK_UP, myNumber)) {
		move(dt, 0.001);
		moving.update(dt);
	} else {
		stop(dt, 0.01);
	}
	if (inputManager.isKeyPress(SDLK_a, myNumber) && timeFire > 500 && fire.ready()) {
		timeFire = 0;
		fire.setX(x).setY(y);
		fire.enable(angle, this);
		collisionManager.add(COLLIDING_FIRE, &fire);
	}
	return *this;
}


void Catherine::render(SDL_Surface *screen) {
	Player::render(screen);
	if (fire.ready() == false) fire.render(screen);
}


